//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef GRAPHCTRL_H_
#define GRAPHCTRL_H_

#include "def.h"
#include <list>
#include <wx/timer.h>

class CGraphCtrl: public wxPanel, public IGUIBind
{
public:
							CGraphCtrl(wxWindow* parent, wxWindowID id=wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
	virtual 				~CGraphCtrl();
	
	//IGUIBind
	virtual void			SetMaxVal(unsigned int nVal)		{ m_nMaxVal = nVal;	}
	virtual unsigned int	GetMaxVal()							{ return m_nMaxVal; }
	virtual void			SetVal(unsigned int nVal);
	virtual void			SetLevel(unsigned char perc);
	virtual void			SetWarningLevel(unsigned char perc) { } 
	virtual void			SetAlarmLevel(unsigned char perc)	{ }
	virtual void 			SetVal(const wxString& str)			{ }


protected:
	void					OnSize(wxSizeEvent& event);
	void					OnPaint(wxPaintEvent& event);
	void 					OnTimer(wxTimerEvent& event);

private:
	void					DrawGrid(class wxBufferedPaintDC& dc);
	void					DrawGraph(class wxBufferedPaintDC& dc);

private:
	unsigned char 			m_btLevel;
	unsigned int			m_nMaxVal;
	
	typedef std::list<unsigned char>	GRAPHVALS;
	GRAPHVALS				m_vals;
	wxTimer					m_timer;
};

#endif /*GRAPHCTRL_H_*/
